﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Text;
using System.Xml;
using System.Text.RegularExpressions;

namespace 热更验证
{
    class MyLoad
    {
        public MyLoad(MyPath my_Path)
        {
            try
            {
                myPath = my_Path;
                index = my_Path.index;
                temp = new StringBuilder();
                messageBuilder = new StringBuilder();
                Message = default;
                chackAll = false;
                chackXml = false;
                tempMessage = default;
                SetTypes();
            }
            catch (Exception)
            {
                throw;
            }
        }

        public Hashtable petSeriseTable = default;
        public Hashtable psIDTable = default;
        public Hashtable chestTable = default;
        public Dictionary<string, FieldInfo> petTypeDic = default;
        public Dictionary<string, int> upgradeConditionDic = default;
        public List<Hashtable> datalist = default;
        public HashK<string, string> petNameHK = default;
        public HashK<string, string> itemsHK = default;
        public HashK<string, string> megaLvSysHK = default;
        public HashK<string, string> dropHK = default;
        public HashK<string, string> evolutionConditionHK = default;
        public HashK<string, ResetEvolutionList> resetEvolutionListHK = default;
        public HashK<string, StringBuilder> randomListHK = default;
        public HashK<string, string> pmAbilityHK = default;
        public HashK<string, string> pokeCharacterClearHK = default;
        public HashK<string, HashSet<string>> pmCharacteristicHK = default;
        public HashK<string, Ability> abilityHK = default;
        public HashK<string, Disintegrate> disintegrateHK = default;
        public HashK<string, StarItemList> starItemListHK = default;
        public HashK<string, StarCondition035> starCondition035HK = default;
        public HashK<string, StarCondition124> starCondition124HK = default;
        public HashK<string, StarContent> starContent124HK = default;
        public HashK<string, string> starLevelCost4HK = default;
        public HashK<string, StarLevelCost> starLevelCost124HK = default;
        public HashK<string, PmMove> pmMoveHK = default;
        public HashK<string, bool> gskillHK = default;
        public HashK<string, HashSet<string>> growSkillHK = default;
        public HashK<string, HashSet<string>> studySkillHK = default;
        public HashK<string, bool> sskillHK = default;
        public HashK<string, PmBuffList> pmBuffListHK = default;
        public HashK<string, string> pmBuffHK = default;
        public HashK<string, string> zMoveHK = default;
        


        //public delegate void Loader();

        int index;

        bool chackXml;

        MyPath myPath;

        StringBuilder messageBuilder;

        StringBuilder temp;

        Type types;

        /// <summary>
        /// 热更数据验证详细信息
        /// </summary>
        public string dataInfo;

        private string tempMessage;
        /// <summary>
        /// 获取临时错误信息
        /// </summary>
        public string TempMessage
        {
            get { return tempMessage; }
        }

        bool chackAll;
        /// <summary>
        /// 获取XML读取是否异常
        /// </summary>
        public bool ChackAll
        {
            get { return chackAll; }
        }

        private string message;
        /// <summary>
        /// 获取和设置XML读取错误信息
        /// </summary>
        public string Message
        {
            get { return message; }
            set { message = value; }
        }

        /// <summary>
        /// 设置类型
        /// </summary>
        void SetTypes()
        {
            switch (index)
            {
                case 0:
                    types = typeof(Riyue);
                    break;

                case 1:
                    types = typeof(Juedou);
                    break;

                case 2:
                    types = typeof(Xinmiaomiao);
                    break;

                case 3:
                    types = typeof(Xinnixi);
                    break;

                case 4:
                    types = typeof(Xinshidai);
                    break;

                case 5:
                    types = typeof(RiyueTY);
                    break;
            }
        }

        /// <summary>
        /// 添加错误信息头部
        /// </summary>
        void Start(string str)
        {
            temp.AppendLine(str);
            chackXml = true;
        }

        /// <summary>
        /// 添加错误信息内容
        /// </summary>
        void Add(string info)
        {
            temp.AppendLine(info);
            chackXml = false;
            chackAll = false;
        }

        /// <summary>
        /// 结束添加错误信息
        /// </summary>
        void End()
        {
            if (!chackXml)
            {
                messageBuilder.Append(temp.ToString());
                temp.Clear();
            }
            else
            {
                temp.Clear();
            }
        }

        /// <summary>
        /// 获取 XML（一对一）并输出重复 ID ， key 为第一列字段
        /// </summary>
        /// <param name="path"> XML 路径</param>
        /// <param name="y"> value 所在的字段索引，key 的索引为 0 ，value 的索引从 1 开始</param>
        /// <param name="xmlName"> xml名称 </param>
        HashK<string, string> GetXmlXtoY(string path, int y,string xmlName)
        {
            XmlLoader loader = default;
            Start(xmlName + "表存在错误：");
            try
            {
                loader = new XmlLoader(path);

            }
            catch (Exception)
            {
                throw;
            }

            if (loader.IsRepeate()) //判断是否存在重复的 key
            {
                HashSet<string> set = loader.GetRepeate();
                string nodeX = loader.NodeX;
                foreach (var item in set)
                {
                    if (!string.IsNullOrEmpty(item) & item != "0") Add(String.Format("当前字段的值重复出现{0} : {1},", nodeX, item));
                }
            }
            End();
            return loader.XtoY(y);
        }

        /// <summary>
        /// 获取 XML（一对一）并输出重复 ID ， 任意位置索引，索引从 0 开始
        /// </summary>
        /// <param name="path">XML 路径</param>
        /// <param name="x"> key 所在的字段索引 </param>
        /// <param name="y"> value 所在的字段索引 </param>
        /// <param name="xmlName"> xml名称 </param>
        HashK<string, string> GetXmlXtoY(string path, int x, int y,string xmlName)
        {
            XmlLoader loader = default;
            Start(xmlName + "表存在错误：");
            try
            {
                loader = new XmlLoader(path, x);

            }
            catch (Exception)
            {
                throw;
            }

            if (loader.IsRepeate()) //判断是否存在重复的 key
            {
                HashSet<string> set = loader.GetRepeate();
                string nodeX = loader.NodeX;
                foreach (var item in set)
                {
                    if (!string.IsNullOrEmpty(item) & item != "0" ) Add(String.Format("当前字段的值重复出现 {0} : {1}", nodeX, item));
                }
            }
            End();
            return loader.AnyWhere(y);
        }

        /// <summary>
        /// 获取类的字段名和公共字段引用对象
        /// </summary>
        /// <param name="type">需要反射的类型</param>
        /// <returns>返回一个 key（字段名）/value（公共字段引用对象）的字典</returns>
        Dictionary<string, FieldInfo> GetTypeDic()
        {
            Dictionary<string, FieldInfo> typeInfoDic = new Dictionary<string, FieldInfo>();
            FieldInfo[] fi = types.GetFields();
            for (int i = 0; i < fi.Length; i++) typeInfoDic.Add(fi[i].Name, fi[i]);
            return typeInfoDic;
        }

        /// <summary>
        /// 读取相关XML文件
        /// </summary>
        /// <returns>读取是否存在异常情况，true为正常</returns>
        public bool LoadAllXml()
        {
            LoadPetName();
            LoadPmMove();
            LoadStarCondition();
            LoadAbility();
            LoadSkill();
            LoadPmAbility();
            LoadItems();
            LoadPmCharacteristic();
            LoadEvolutionCondition();

            switch (index)
            {
                case 0: //日月
                    LoadResetEvolutionList();
                    LoadStarItemList();
                    LoadzMove();
                    break;

                case 1: //决斗
                    LoadPokeCharacter();
                    LoadMegaLvSys();
                    LoadStarContent();
                    LoadStarLevelCost();
                    LoadDisintegrate();
                    LoadzMove();
                    break;

                case 2: //新喵喵
                    LoadStarContent();
                    LoadStarLevelCost();
                    LoadPokeCharacter();
                    LoadDisintegrate();
                    break;

                case 3: //新逆袭
                    LoadStarItemList();
                    LoadDrop();
                    LoadzMove();
                    LoadupgradeCondition();
                    break;

                case 4: //新世代
                    LoadStarContent();
                    LoadStarLevelCost();
                    LoadDrop();
                    LoadzMove();
                    break;

                case 5: //通用类型日月
                    LoadResetEvolutionList();
                    LoadStarItemList();
                    //LoadzMove;
                    break;
            }

            LoadPets();
            

            if (!chackAll) Message = messageBuilder.ToString();
            
            return chackAll;
        }

        /// <summary>
        /// 读取 chest (宝箱) 表
        /// </summary>
        /// <returns>读取是否存在异常情况，true为正常</returns>
        public bool LoadChest()
        {
            try
            {
                tempMessage = default;
                temp.Clear();
                temp.AppendLine("chest 表存在错误：");
                chackXml = true;
                using (XmlTextReader reader = new XmlTextReader(myPath.randomListPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    randomListHK = new HashK<string, StringBuilder>();
                    StringBuilder builder;
                    string randomListId;
                    string randomItemsId;
                    while (reader.Read())
                    {
                        reader.ReadToFollowing("randomListId");
                        randomListId = reader.ReadString();
                        reader.ReadToFollowing("randomItemsId");
                        randomItemsId = reader.ReadString();
                        if (reader.EOF) break;
                        if (!itemsHK.ContainsKey(randomItemsId))
                        {
                            temp.AppendLine("items 表中不存在该 randomListId：" + randomListId);
                            randomListId = "randomListId错误";
                            chackXml = false;
                        }
                        if (randomListHK.ContainsKey(randomListId))
                        {
                            randomListHK.GetTvalue(randomListId).Append(itemsHK[randomItemsId] + ",");
                        }
                        else
                        {
                            builder = new StringBuilder();
                            builder.Append(itemsHK[randomItemsId] + ",");
                            randomListHK.Add(randomListId, builder);
                        }
                    }
                }

                using (XmlTextReader reader = new XmlTextReader(myPath.chestPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    chestTable = new Hashtable();
                    string[] items = new string[30];
                    for (int i = 0; i < 30; i++)
                    {
                        items[i] = "item" + (i + 1).ToString();
                    }
                    while (reader.Read())
                    {
                        Chest chest = new Chest();
                        reader.ReadToFollowing("chestId");
                        chest.chestId = reader.ReadString();
                        reader.ReadToFollowing("chestName");
                        chest.chestName = reader.ReadString();
                        reader.ReadToFollowing("chestQuality");
                        chest.chestQuality = reader.ReadString();
                        reader.ReadToFollowing("chestType");
                        chest.chestType = reader.ReadString();
                        reader.ReadToFollowing("randomNumList2Id");
                        chest.randomNumList2Id = reader.ReadString();
                        if (reader.EOF) break;
                        if (Int32.Parse(chest.chestType) < 4)
                        {
                            StringBuilder builder = new StringBuilder();
                            string item = null;
                            bool chack = true;
                            for (int i = 0; i < items.Length; i++)
                            {
                                reader.ReadToFollowing(items[i]);
                                item = reader.ReadString();
                                if (!itemsHK.ContainsKey(item) & item != "0")
                                {
                                    temp.AppendLine("宝箱 " + chest.chestId + " 存在错误 itemID：" + item);
                                    chackXml = false;
                                    chack = false;
                                }
                                else
                                {
                                    builder.Append(itemsHK[item] + ",");
                                }
                            }
                            if (chack)
                            {
                                chest.items = builder.ToString();
                            }
                            else
                            {
                                builder.Clear();
                                chest.items = "***存在错误 itemID***";
                            }

                        }
                        else
                        {
                            if (!randomListHK.ContainsKey(chest.randomNumList2Id))
                            {
                                temp.AppendLine("宝箱 " + chest.chestId + " 存在错误 randomNumList2Id：" + chest.randomNumList2Id);
                                chackXml = false;
                                chest.items = "randomNumList2Id错误";
                            }
                            else
                            {
                                chest.items = randomListHK[chest.randomNumList2Id].ToString();
                            }

                        }

                        if (chestTable.ContainsKey(chest.chestId))
                        {
                            temp.AppendLine("chestId 重复：" + chest.chestId);
                            chackXml = false;
                        }
                        else
                        {
                            chestTable.Add(chest.chestId, chest);
                        }
                    }
                }

                foreach (string item in chestTable.Keys)
                {
                    if (itemsHK.ContainsKey(item)) 
                    {
                        temp.AppendLine("chestId 与 itemId 重复：" + item);
                        chackXml = false;
                    }
                }

                if (!chackXml)
                {
                    tempMessage = temp.ToString();
                    temp.Clear();
                }

                return chackXml;
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取热更数据
        /// </summary>
        /// <returns>读取是否存在异常情况，true为正常</returns>
        public bool LoadData()
        {
            datalist = new List<Hashtable>();
            Hashtable hashtable = new Hashtable();
            tempMessage = default;
            chackXml = true;
            temp.Clear();
            temp.AppendLine("策划提供的参考数据存在错误：");
            try
            {
                using (XmlTextReader reader = new XmlTextReader(myPath.dataPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    while (reader.Read())
                    {
                        if (reader.Depth == 2 & reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                                case "characteristic":
                                    string temp = reader.ReadString();
                                    string strs = Regex.Replace(temp, @"[+]|[/]", ",");
                                    strs = Regex.Replace(strs, @"\s|\d|[[]|[]]|[']|[--]|[a-zA-Z]|[特性]", "");
                                    strs = Regex.Replace(strs, @"^,", "");
                                    if (strs.Length == 0)
                                    {
                                        hashtable.Add(reader.Name, temp);
                                    }
                                    else
                                    {
                                        hashtable.Add(reader.Name, new HashSet<string>(strs.Split(',')));
                                    }
                                    break;
                                default:
                                    string datastr = reader.ReadString().Trim();
                                    if (!string.IsNullOrEmpty(datastr))
                                    {
                                        hashtable.Add(reader.Name, datastr);
                                    }
                                    break;
                            }
                        }
                        if (reader.Depth == 1 & reader.NodeType == XmlNodeType.EndElement)
                        {
                            datalist.Add(hashtable);
                            hashtable = new Hashtable();
                        }
                    }
                }
            }
            catch (Exception e)
            {
                temp.AppendLine(e.Message);
                chackXml = false;
            }
            if (!chackXml)
            {
                tempMessage = temp.ToString();
                temp.Clear();
            }
            return chackXml;
        }

        /// <summary>
        /// 验证热更数据
        /// </summary>
        /// <returns>数据验证信息</returns>
        public string DataEqual()
        {
            tempMessage = default;
            temp.Clear();
            temp.AppendLine("------ 开始验证 ------");
            dataInfo = null;
            StringBuilder builder = new StringBuilder();
            foreach (Hashtable data in datalist)
            {
                string petname = data["petName"].ToString();
                temp.AppendLine(string.Format("\n->>>>>>>>>> {0} <<<<<<<<<<-", petname));
                builder.AppendLine(string.Format("\n->>>>>>>>>> 精灵 {0} 开始 <<<<<<<<<<-", petname));
                if (!petNameHK.ContainsKey(petname))
                {
                    temp.AppendLine(string.Format("【 pets 表中不存在该精灵：{0} 】\n", petname));
                    builder.AppendLine(string.Format("【 pets 表中不存在该精灵：{0} 】\n", petname));
                }
                else
                {
                    string petid = petNameHK.GetTvalue(petname);

                    if (index != 5 & index != 3)
                    {
                        string seriseid = psIDTable[petid].ToString();
                        List<object> objs = petSeriseTable[seriseid] as List<object>;

                        foreach (var myobj in objs)
                        {
                            ChackData(myobj);
                        }
                    }
                    else
                    {
                        object myobj = psIDTable[petid];
                        ChackData(myobj);
                    }

                    void ChackData(object obj)
                    {
                        string petname2 = petTypeDic["petName"].GetValue(obj).ToString();

                        if (petname == petname2)
                        {
                            string petAbilityId = petTypeDic["petAbilityId"].GetValue(obj).ToString();
                            Ability ability = abilityHK.GetTvalue(petAbilityId);
                            string temp1 = default;
                            string temp2 = default;

                            foreach (string item in data.Keys)
                            {
                                switch (item)
                                {
                                    case "hp":
                                        temp1 = ability.hp;
                                        temp2 = data[item].ToString();
                                        break;
                                    case "physicalDamage":
                                        temp1 = ability.physicalDamage;
                                        temp2 = data[item].ToString();
                                        break;
                                    case "physicalDefence":
                                        temp1 = ability.physicalDefence;
                                        temp2 = data[item].ToString();
                                        break;
                                    case "specialDamage":
                                        temp1 = ability.specialDamage;
                                        temp2 = data[item].ToString();
                                        break;
                                    case "specialDefence":
                                        temp1 = ability.specialDefence;
                                        temp2 = data[item].ToString();
                                        break;
                                    case "speed":
                                        temp1 = ability.speed;
                                        temp2 = data[item].ToString();
                                        break;
                                    case "characteristic":
                                        HashSet<string> set1;
                                        HashSet<string> set2;
                                        temp1 = petTypeDic[item].GetValue(obj).ToString();
                                        if (data[item].GetType() == typeof(string))
                                        {
                                            set1 = pmCharacteristicHK.GetTvalue(temp1);
                                            set2 = pmCharacteristicHK.GetTvalue(data[item].ToString());
                                            if (set2.SetEquals(set1))
                                            {
                                                temp2 = temp1 = GetStr(set1);
                                            }
                                            else
                                            {
                                                temp1 = GetStr(set1);
                                                temp2 = GetStr(set2);
                                            }
                                        }
                                        else
                                        {
                                            set1 = pmCharacteristicHK.GetTvalue(temp1);
                                            set2 = data[item] as HashSet<string>;
                                            bool isOK = true;
                                            foreach (var myitem in set1)
                                            {
                                                if (!set2.Contains(pmAbilityHK.GetTvalue(myitem)))
                                                {
                                                    isOK = false;
                                                    break;
                                                }
                                            }
                                            
                                            if (isOK)
                                            {
                                                temp2 = temp1 = GetStr(set2);
                                            }
                                            else
                                            {
                                                temp1 = GetStr(set1);
                                                temp2 = GetStr(set2);
                                            }
                                        }
                                        
                                        string GetStr(HashSet<string> myset)
                                        {
                                            StringBuilder mybuilder = new StringBuilder();
                                            foreach (var myitem in myset)
                                            {
                                                if (Regex.IsMatch(myitem,@"[0-9]"))
                                                {
                                                    if (pmAbilityHK.ContainsKey(myitem))
                                                    {
                                                        mybuilder.Append(pmAbilityHK.GetTvalue(myitem) + " ");
                                                    }
                                                    else
                                                    {
                                                        mybuilder.Append("异常特性 ");
                                                    }
                                                }
                                                else
                                                {
                                                    mybuilder.Append(myitem + " ");

                                                }
                                            }
                                            return mybuilder.ToString();
                                        }

                                        break;
                                    case "megaStrengthenId":
                                        temp1 = petTypeDic[item].GetValue(obj).ToString();
                                        temp2 = data[item].ToString();
                                        string[] mids = temp2.Split(',');
                                        temp2 = mids[0];
                                        bool isOK2 = true;
                                        temp1 += GetMAbility(temp1);
                                        temp2 += GetMAbility(temp2);

                                        if (!isOK2)
                                        {
                                            temp1 += " 与参考M特性不一致";
                                        }

                                        string GetMAbility(string str)
                                        {
                                            if (megaLvSysHK.ContainsKey(str))
                                            {
                                                
                                                string mg1 = default;
                                                if (mids.Length > 1) 
                                                {
                                                    mg1 = megaLvSysHK.GetTvalue(str);
                                                    if (mg1 != mids[1])
                                                    {
                                                        isOK2 = false;
                                                    }
                                                }

                                                string mg2 = default;
                                                if (mids.Length > 2)
                                                {
                                                    if (pmAbilityHK.ContainsKey(mg1))
                                                    {
                                                        mg2 = pmAbilityHK.GetTvalue(mg1);
                                                        if (mg2 != mids[2])
                                                        {
                                                            isOK2 = false;
                                                        }
                                                    }
                                                    else
                                                    {
                                                        return " M 特性不存在";
                                                    }
                                                }
                                                return " " + mg2;
                                            }
                                            else
                                            {
                                                return " megaStrengthenId 不存在";
                                            }
                                        }
                                        break;
                                    default:
                                        if (petTypeDic.ContainsKey(item))
                                        {
                                            temp1 = petTypeDic[item].GetValue(obj).ToString();
                                            temp2 = data[item].ToString();
                                        }
                                        else
                                        {
                                            temp1 = temp2 = item + "(无)";
                                        }
                                        break;
                                }

                                if (temp1 != temp2)
                                {
                                    temp.AppendLine(string.Format("*** {0} 字段不一致 ***\n【XML：{1}，参考：{2}】", item, temp1, temp2));
                                    builder.AppendLine(string.Format("*** {0} 字段不一致 ***\n【XML：{1}，参考：{2}】", item, temp1, temp2));
                                }

                                builder.AppendLine(string.Format("【{0}】 XML：{1}，参考：{2}", item, temp1, temp2));

                            }

                            switch (index)
                            {
                                case 0:
                                    AIChack();
                                    break;

                                case 1:
                                    AIChack();
                                    break;

                                case 2:
                                    AIChack();
                                    break;

                                case 3:
                                    AIChack();
                                    break;

                                case 4:
                                    AIChack();
                                    break;

                                case 5:
                                    AIChack();
                                    break;
                            }

                            void AIChack()
                            {
                                MyChack myChack = new MyChack(this, obj, index);
                                if (!myChack.ChackAll())
                                {
                                    temp.AppendLine(myChack.Message);
                                }
                                builder.AppendLine(myChack.InfoMessage);
                            }

                        }
                    }

                }
                builder.AppendLine(string.Format("<<<<<<<<<<- 精灵 {0} 结束 ->>>>>>>>>>", petname));
            }
            temp.AppendLine("\n------ 结束验证 ------");
            tempMessage = temp.ToString();
            temp.Clear();
            dataInfo = builder.ToString();
            builder.Clear();
            return tempMessage;
        }


        /// <summary>
        /// 读取 pets 表
        /// </summary>
        void LoadPets()
        {
            XmlTextReader petReader = null;
            Start("pet 表存在错误：");
            try
            {
                petReader = new XmlTextReader(myPath.petPath);
                petReader.WhitespaceHandling = WhitespaceHandling.None;
                petTypeDic = GetTypeDic();
            }
            catch (Exception)
            {
                throw;
            }

            //精灵ID + 系列ID
            object obj = Activator.CreateInstance(types);
            string petId = default;
            string seriseId = default;
            string nextPetId = default;
            psIDTable = new Hashtable();
            //系列ID + 精灵类的实例引用
            petSeriseTable = new Hashtable();
            List<object> petInstanceList;

            if (index == 3)
            {
                while (petReader.Read())
                {
                    if (petReader.Depth == 2 & petReader.NodeType == XmlNodeType.Element)
                    {
                        string nodeName = petReader.Name;

                        if (petTypeDic.ContainsKey(nodeName))
                        {
                            switch (nodeName)
                            {
                                case "petId":
                                    petId = petReader.ReadString();
                                    petTypeDic[nodeName].SetValue(obj, petId); //设置 petId 的值
                                    break;

                                case "nextPetId":
                                    nextPetId = petReader.ReadString();
                                    petTypeDic[nodeName].SetValue(obj, nextPetId); //设置 nextPetId 的值
                                    break;

                                case "zMove":
                                    string zMove = petReader.ReadString();
                                    petTypeDic[nodeName].SetValue(obj, zMove); //设置 zMove 的值
                                    if (zMoveHK.Contains(zMove))
                                    {
                                        petTypeDic["zMoveBuff"].SetValue(obj, zMoveHK[zMove].ToString());
                                    }
                                    else
                                    {
                                        petTypeDic["zMoveBuff"].SetValue(obj, zMove);
                                    }
                                    break;

                                default:
                                    petTypeDic[nodeName].SetValue(obj, petReader.ReadString()); //设置其他字段的值
                                    break;
                            }
                        }
                    }
                    if (petReader.Depth == 1 & petReader.NodeType == XmlNodeType.EndElement)
                    {
                        if (!psIDTable.ContainsKey(petId))
                        {
                            if (!petSeriseTable.ContainsKey(nextPetId)) //如果 nextPetId 不存在
                            {
                                petSeriseTable.Add(petId, nextPetId);
                            }
                            else //如果 nextPetId 存在
                            {
                                Add("petId[ " + petId + " ]/nextPetId 重复：" + nextPetId);
                            }
                            psIDTable.Add(petId, obj);
                        }
                        else Add("petId 重复：" + petId);

                        obj = Activator.CreateInstance(types);
                    }
                }
            }
            else
            {
                while (petReader.Read())
                {
                    if (petReader.Depth == 2 & petReader.NodeType == XmlNodeType.Element)
                    {
                        string nodeName = petReader.Name;

                        if (petTypeDic.ContainsKey(nodeName))
                        {
                            switch (nodeName)
                            {
                                case "petId":
                                    petId = petReader.ReadString();
                                    petTypeDic[nodeName].SetValue(obj, petId); //设置 petId 的值
                                    if (index == 1 || index == 2)
                                    {
                                        if (pokeCharacterClearHK.ContainsKey(petId))
                                        {
                                            petTypeDic["pokeCharacterClearId"].SetValue(obj, pokeCharacterClearHK[petId].ToString());
                                        }
                                        else
                                        {
                                            petTypeDic["pokeCharacterClearId"].SetValue(obj, "异常");
                                        }
                                        petTypeDic["disintegrate"].SetValue(obj, ""); //设置 disintegrate 的值
                                    }
                                    break;

                                case "serise":
                                    seriseId = petReader.ReadString();
                                    petTypeDic[nodeName].SetValue(obj, seriseId); //设置 serise 的值
                                    break;

                                case "zMove":
                                    string zMove = petReader.ReadString();
                                    petTypeDic[nodeName].SetValue(obj, zMove); //设置 zMove 的值
                                    if (zMoveHK.Contains(zMove))
                                    {
                                        petTypeDic["zMoveBuff"].SetValue(obj, zMoveHK[zMove].ToString());
                                    }
                                    else
                                    {
                                        petTypeDic["zMoveBuff"].SetValue(obj, zMove);
                                    }
                                    break;

                                default:
                                    petTypeDic[nodeName].SetValue(obj, petReader.ReadString()); //设置其他字段的值
                                    break;
                            }
                        }
                    }
                    if (petReader.Depth == 1 & petReader.NodeType == XmlNodeType.EndElement)
                    {
                        if (!petSeriseTable.ContainsKey(seriseId)) //如果 系列ID 不存在
                        {
                            petInstanceList = new List<object>();
                            petInstanceList.Add(obj);
                            petSeriseTable.Add(seriseId, petInstanceList);
                        }
                        else //如果 系列ID 存在
                        {
                            (petSeriseTable[seriseId] as List<object>).Add(obj);
                        }
                        psIDTable.Add(petId, seriseId);
                        obj = Activator.CreateInstance(types);
                    }
                }
                CheckSeriseID();
            }

            petReader.Close();

            void CheckSeriseID()
            {
                foreach (var seriseId2 in petSeriseTable.Keys)
                {
                    List<object> items = petSeriseTable[seriseId2] as List<object>;

                    for (int i = 0; i < items.Count; i++)
                    {
                        string netxtID = petTypeDic["nextPetId"].GetValue(items[i]) as string;
                        if (netxtID != "0" & netxtID != null)
                        {
                            if (psIDTable.ContainsKey(netxtID))
                            {
                                string seriseId3 = psIDTable[netxtID].ToString();
                                if (seriseId3 != seriseId2.ToString())
                                {
                                    Add("系列 " + seriseId2 + " 存在错误的进化ID：" + netxtID + " (系列ID " + seriseId3 + ")");
                                }
                            }
                            else
                            {
                                string petId2 = petTypeDic["petId"].GetValue(items[i]) as string;
                                Add(string.Format("当前系列ID[ {0} ]中的精灵[ {1} ]存在异常进化ID[ {2} ]", seriseId2, petId2, netxtID));
                            }

                        }
                    }
                }
            }
            End();
        }

        /// <summary>
        /// 读取 pet 表 获取精灵和精灵名称
        /// </summary>
        void LoadPetName()
        {
            try
            {
                if (index == 3) petNameHK = GetXmlXtoY(myPath.petPath, 4, 0, "pets");
                else petNameHK = GetXmlXtoY(myPath.petPath, 3, 0 ,"pets");
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 ability（种族值） 表
        /// </summary>
        void LoadAbility()
        {
            XmlTextReader abilityReader = null;
            Start("ability 表存在错误：");
            try
            {
                abilityReader = new XmlTextReader(myPath.abilityPath);
                abilityReader.WhitespaceHandling = WhitespaceHandling.None;
            }
            catch (Exception)
            {
                throw;
            }

            abilityHK = new HashK<string, Ability>();
            Ability ability = new Ability();
            string petAbilityId = null;
            while (abilityReader.Read())
            {
                if (abilityReader.Depth == 2 & abilityReader.NodeType == XmlNodeType.Element)
                {
                    string nodeName = abilityReader.Name;
                    switch (nodeName)
                    {
                        case "petAbilityId":
                            petAbilityId = abilityReader.ReadString();
                            break;

                        case "hp":
                            ability.hp = abilityReader.ReadString();
                            break;

                        case "physicalDamage":
                            ability.physicalDamage = abilityReader.ReadString();
                            break;

                        case "physicalDefence":
                            ability.physicalDefence = abilityReader.ReadString();
                            break;

                        case "specialDamage":
                            ability.specialDamage = abilityReader.ReadString();
                            break;

                        case "specialDefence":
                            ability.specialDefence = abilityReader.ReadString();
                            break;

                        case "speed":
                            ability.speed = abilityReader.ReadString();
                            break;
                    }
                }
                if (abilityReader.Depth == 1 & abilityReader.NodeType == XmlNodeType.EndElement)
                {
                    if (abilityHK.ContainsKey(petAbilityId)) Add("petAbilityId 重复：" + petAbilityId);
                    else
                    {
                        abilityHK.Add(petAbilityId, ability);
                        ability = new Ability();
                    }
                }
            }
            abilityReader.Close();
            
            End();
        }

        /// <summary>
        /// 读取 技能ID 对应的技能表
        /// </summary>
        void LoadSkill()
        {
            XmlTextReader growSkillReader = null;
            XmlTextReader studySkillReader = null;
            Start("growSkill & studySkill 表存在错误：");
            try
            {
                //成长技能
                growSkillReader = new XmlTextReader(myPath.growSkillPath);
                growSkillReader.WhitespaceHandling = WhitespaceHandling.None;

                //学习机
                studySkillReader = new XmlTextReader(myPath.studySkillPath);
                studySkillReader.WhitespaceHandling = WhitespaceHandling.None;
            }
            catch (Exception)
            {
                throw;
            }

            gskillHK = new HashK<string, bool>();
            sskillHK = new HashK<string, bool>();

            string skill = "";
            XmlTextReader reader = null;
            HashK<string, bool> tskillHK = null;
            HashSet<string> hs = new HashSet<string>();
            HashK<string, HashSet<string>> tempHK = null;

            void CheckXml(string temp)
            {
                if (skill != temp)
                {
                    skill = temp;

                    //判断 SkillId 是否添加进 tempHK <str/set>
                    if (tempHK.ContainsKey(skill)) hs = tempHK.GetTvalue(skill);
                    else
                    {
                        //没添加过 SkillId ：
                        hs = new HashSet<string>();
                        tempHK.Add(skill, hs);
                    }

                    //判断 SkillId 是否 没 被添加进 skillHK <str/boo> 
                    if (!tskillHK.ContainsKey(skill)) tskillHK.Add(skill, true);
                }
            }

            for (int i = 0; i < 2; i++)
            {
                string name = "";
                switch (i)
                {
                    case 0:
                        name = "growSkill";
                        reader = growSkillReader;
                        tskillHK = gskillHK;
                        growSkillHK = tempHK = new HashK<string, HashSet<string>>();
                        break;

                    case 1:
                        name = "studySkill";
                        reader = studySkillReader;
                        tskillHK = sskillHK;
                        studySkillHK = tempHK = new HashK<string, HashSet<string>>();
                        break;
                }
                while (reader.Read())
                {
                    if (reader.Depth == 2 & reader.NodeType == XmlNodeType.Element)
                    {
                        string temp = reader.ReadString();
                        switch (reader.Name)
                        {
                            case "growSkillId":
                                CheckXml(temp);
                                break;

                            case "studySkillId":
                                CheckXml(temp);
                                break;

                            case "skillId":
                                //判断 skillId 是否 未 被添加过
                                if (!hs.Add(temp))
                                {
                                    //添加过：
                                    Add(name + ": " + skill + " ，skillId 重复： " + temp); //输出提示
                                    tskillHK[skill] = false; // skillHK <str/boo>，growSkillId 对应的值改成 false
                                }
                                break;
                        }
                    }
                }
                reader.Close();
            }
            
            End();
        }

        /// <summary>
        /// 读取 日月 pmMove（所有技能） 表
        /// </summary>
        void LoadPmMove()
        {
            try
            {
                Start("pmMove 表存在错误：");
                using (XmlTextReader reader = new XmlTextReader(myPath.pmMovePath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    pmMoveHK = new HashK<string, PmMove>();
                    PmMove pmMove = new PmMove();
                    string pmActiveMoveId = "";

                    while (reader.Read())
                    {
                        reader.ReadToFollowing("pmActiveMoveId");
                        pmActiveMoveId = reader.ReadString();

                        reader.ReadToFollowing("pmAcitveMoveName");
                        pmMove.pmAcitveMoveName = reader.ReadString();

                        reader.ReadToFollowing("pmMoveBasicMode");
                        pmMove.pmMoveBasicMode = reader.ReadString();

                        reader.ReadToFollowing("pmMoveType");
                        pmMove.pmMoveType = reader.ReadString();

                        if (reader.EOF == true) return;

                        if (!pmMoveHK.ContainsKey(pmActiveMoveId))
                        {
                            pmMoveHK.Add(pmActiveMoveId, pmMove);
                            pmMove = new PmMove();
                        }
                        else
                        {
                            Add("pmActiveMoveId 重复： " + pmActiveMoveId);
                        }
                    }
                }
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 pmAbility（所有特性） 表
        /// </summary>
        void LoadPmAbility()
        {
            try
            {
                pmAbilityHK = GetXmlXtoY(myPath.pmAbilityPath, 1, "pmAbility");
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 items（所有物品） 表
        /// </summary>
        void LoadItems()
        {
            try
            {
                itemsHK = GetXmlXtoY(myPath.itemsPath, 1, "items");

            }
            catch (Exception)
            {
                throw;
            }

        }

        /// <summary>
        /// 读取 starCondition（升星条件） 表
        /// </summary>
        void LoadStarCondition()
        {
            try
            {
                Start("starCondition 表存在错误：");

                if (index == 0 || index == 5 || index == 3)
                {
                    using (XmlTextReader reader = new XmlTextReader(myPath.starConditionPath))
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        starCondition035HK = new HashK<string, StarCondition035>();
                        StarCondition035 starCondition = new StarCondition035();
                        string starIncreaseCondition = "";

                        while (reader.Read())
                        {
                            reader.ReadToFollowing("starIncreaseCondition");
                            starIncreaseCondition = reader.ReadString();

                            if (reader.EOF == false)
                            {
                                reader.ReadToFollowing("levelItemListId1");
                                starCondition.levelItemListId1 = reader.ReadString();

                                reader.ReadToFollowing("levelItemListId2");
                                starCondition.levelItemListId2 = reader.ReadString();

                                reader.ReadToFollowing("levelItemListId3");
                                starCondition.levelItemListId3 = reader.ReadString();

                                reader.ReadToFollowing("levelItemListId4");
                                starCondition.levelItemListId4 = reader.ReadString();

                                reader.ReadToFollowing("levelItemListId5");
                                starCondition.levelItemListId5 = reader.ReadString();

                                reader.ReadToFollowing("levelItemListId6");
                                starCondition.levelItemListId6 = reader.ReadString();

                                if (index == 3)
                                {
                                    reader.ReadToFollowing("levelItemListId7");
                                    starCondition.levelItemListId7 = reader.ReadString();

                                    reader.ReadToFollowing("levelItemListId8");
                                    starCondition.levelItemListId8 = reader.ReadString();

                                    reader.ReadToFollowing("levelItemListId9");
                                    starCondition.levelItemListId9 = reader.ReadString();

                                    reader.ReadToFollowing("levelItemListId10");
                                    starCondition.levelItemListId10 = reader.ReadString();

                                    reader.ReadToFollowing("levelItemListId11");
                                    starCondition.levelItemListId11 = reader.ReadString();

                                    reader.ReadToFollowing("levelItemListId12");
                                    starCondition.levelItemListId12 = reader.ReadString();
                                }
                                
                                if (starCondition035HK.ContainsKey(starIncreaseCondition))
                                {
                                    Add("starIncreaseCondition 重复：" + starIncreaseCondition);
                                }
                                else
                                {
                                    starCondition035HK.Add(starIncreaseCondition, starCondition);
                                    starCondition = new StarCondition035();
                                }
                            }
                        }
                    }
                }
                else if (index == 1 || index == 2 || index == 4)
                {
                    using (XmlTextReader reader = new XmlTextReader(myPath.starConditionPath))
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        starCondition124HK = new HashK<string, StarCondition124>();
                        StarCondition124 starCondition = new StarCondition124();
                        string starIncreaseCondition = "";

                        while (reader.Read())
                        {
                            reader.ReadToFollowing("starIncreaseCondition");
                            starIncreaseCondition = reader.ReadString();

                            if (index == 4)
                            {
                                reader.ReadToFollowing("starUpgradeNextId");
                                starCondition.starUpgradeNextId = reader.ReadString();
                            }
                            else
                            {
                                starCondition.starUpgradeNextId = default;
                            }

                            if (reader.EOF == false)
                            {
                                reader.ReadToFollowing("starContentId_1");
                                starCondition.starContentId_1 = reader.ReadString();

                                reader.ReadToFollowing("starContentId_2");
                                starCondition.starContentId_2 = reader.ReadString();

                                reader.ReadToFollowing("starContentId_3");
                                starCondition.starContentId_3 = reader.ReadString();

                                reader.ReadToFollowing("starContentId_4");
                                starCondition.starContentId_4 = reader.ReadString();

                                reader.ReadToFollowing("starContentId_5");
                                starCondition.starContentId_5 = reader.ReadString();

                                reader.ReadToFollowing("starContentId_6");
                                starCondition.starContentId_6 = reader.ReadString();

                                reader.ReadToFollowing("starContentId_7");
                                starCondition.starContentId_7 = reader.ReadString();

                                reader.ReadToFollowing("starContentId_8");
                                starCondition.starContentId_8 = reader.ReadString();
                                
                                if (starCondition124HK.ContainsKey(starIncreaseCondition))
                                {
                                    Add("starIncreaseCondition 重复：" + starIncreaseCondition);
                                }
                                else
                                {
                                    starCondition124HK.Add(starIncreaseCondition, starCondition);
                                    starCondition = new StarCondition124();
                                }
                            }
                        }
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 starItemList（升星材料） 表 日月
        /// </summary>
        void LoadStarItemList()
        {
            try
            {
                Start("starItemList 表存在错误：");
                using (XmlTextReader reader = new XmlTextReader(myPath.starItemListPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    starItemListHK = new HashK<string, StarItemList>();
                    HashSet<string> set = new HashSet<string>();
                    StarItemList itemList = new StarItemList();
                    string itemListId = "";
                    string item1_id = "";
                    string item2_id = "";
                    string item1_num = "";
                    string item2_num = "";
                    while (reader.Read())
                    {
                        reader.ReadToFollowing("itemListId");
                        itemListId = reader.ReadString();

                        reader.ReadToFollowing("item1_id");
                        item1_id = reader.ReadString();

                        reader.ReadToFollowing("item1_num");
                        item1_num = reader.ReadString();

                        reader.ReadToFollowing("item2_id");
                        item2_id = reader.ReadString();

                        reader.ReadToFollowing("item2_num");
                        item2_num = reader.ReadString();
                        if (reader.EOF == true) return;
                        if (set.Add(itemListId))
                        {
                            itemList = new StarItemList();
                            itemList.item1_id = item1_id;
                            itemList.item2_id = item2_id;
                            itemList.item1_num = item1_num;
                            itemList.item2_num = item2_num;
                            starItemListHK.Add(itemListId, itemList);
                        }
                        else Add("itemListId 重复：" + itemListId);
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 starContent 表（升星节点消耗） 决斗/新喵喵/新世代
        /// </summary>
        void LoadStarContent()
        {
            try
            {
                Start("StarContent 表存在错误：");

                using (XmlTextReader reader = new XmlTextReader(myPath.starContentPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    starContent124HK = new HashK<string, StarContent>();
                    StarContent starContent = new StarContent();
                    string starContentId = "";

                    while (reader.Read())
                    {
                        reader.ReadToFollowing("starContentId");
                        starContentId = reader.ReadString();

                        if (reader.EOF == false)
                        {
                            reader.ReadToFollowing("levelCostId_1");
                            starContent.levelCostId_1 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_2");
                            starContent.levelCostId_2 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_3");
                            starContent.levelCostId_3 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_4");
                            starContent.levelCostId_4 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_5");
                            starContent.levelCostId_5 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_6");
                            starContent.levelCostId_6 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_7");
                            starContent.levelCostId_7 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_8");
                            starContent.levelCostId_8 = reader.ReadString();

                            reader.ReadToFollowing("levelCostId_9");
                            starContent.levelCostId_9 = reader.ReadString();

                            if (starContent124HK.ContainsKey(starContentId))
                            {
                                Add("starContentId 重复：" + starContentId);
                            }
                            else
                            {
                                starContent124HK.Add(starContentId, starContent);
                                starContent = new StarContent();
                            }
                        }
                    }
                }

                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 starLevelCost 表（升星材料） 决斗/新喵喵/新世代
        /// </summary>
        void LoadStarLevelCost()
        {
            try
            {
                Start("starLevelCost 表存在错误：");

                using (XmlTextReader reader = new XmlTextReader(myPath.starLevelCostPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    starLevelCost124HK = new HashK<string, StarLevelCost>();
                    StarLevelCost starLevelCost = new StarLevelCost();
                    string starLevelCostId = "";

                    while (reader.Read())
                    {
                        reader.ReadToFollowing("starLevelCostId");
                        starLevelCostId = reader.ReadString();

                        if (reader.EOF == false)
                        {
                            reader.ReadToFollowing("item_2");
                            starLevelCost.item_2 = reader.ReadString();

                            reader.ReadToFollowing("num_2");
                            starLevelCost.num_2 = reader.ReadString();

                            reader.ReadToFollowing("item_3");
                            starLevelCost.item_3 = reader.ReadString();

                            reader.ReadToFollowing("num_3");
                            starLevelCost.num_3 = reader.ReadString();

                            if (starLevelCost124HK.ContainsKey(starLevelCostId))
                            {
                                Add("starLevelCostId 重复：" + starLevelCostId);
                            }
                            else
                            {
                                starLevelCost124HK.Add(starLevelCostId, starLevelCost);
                                starLevelCost = new StarLevelCost();
                            }
                        }
                    }
                }

                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 pmCharacteristic（普通特性索引） 表
        /// </summary>
        void LoadPmCharacteristic()
        {
            try
            {
                Start("pmCharacteristic 表存在错误：");
                using (XmlTextReader reader = new XmlTextReader(myPath.pmCharacteristicPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    pmCharacteristicHK = new HashK<string, HashSet<string>>();
                    HashSet<string> set;
                    string pokeId = default;
                    string characteristicId = default;

                    while (reader.Read())
                    {
                        reader.ReadToFollowing("pokeId");
                        pokeId = reader.ReadString();

                        reader.ReadToFollowing("characteristicId");
                        characteristicId = reader.ReadString();

                        if (reader.EOF == false)
                        {
                            if (!pmCharacteristicHK.ContainsKey(pokeId))
                            {
                                set = new HashSet<string>();
                                set.Add(characteristicId);
                                pmCharacteristicHK.Add(pokeId, set);
                            }
                            else
                            {
                                set = pmCharacteristicHK.GetTvalue(pokeId);
                                if (!set.Add(characteristicId)) 
                                {
                                    Add("pokeId 出现重复特性：" + pokeId);
                                }
                            }
                        }
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 evolutionCondition（进化条件） 表
        /// </summary>
        void LoadEvolutionCondition()
        {
            try
            {
                Start("evolutionCondition 表存在错误：");
                using (XmlTextReader reader = new XmlTextReader(myPath.evolutionConditionPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    evolutionConditionHK = new HashK<string, string>();
                    HashSet<string> set = new HashSet<string>();
                    StringBuilder builder = new StringBuilder();
                    string evolutionConditionId = "";
                    string needAwakenlevel = "";
                    string itemId1 = "";
                    string itemId2 = "";
                    string itemNum1 = "";
                    string itemNum2 = "";
                    while (reader.Read())
                    {
                        reader.ReadToFollowing("evolutionConditionId");
                        evolutionConditionId = reader.ReadString();

                        if (reader.EOF == false)
                        {
                            if (index == 0 || index == 4)
                            {
                                reader.ReadToFollowing("needAwakenlevel");
                                needAwakenlevel = reader.ReadString();
                            }

                            reader.ReadToFollowing("itemId1");
                            itemId1 = reader.ReadString();

                            reader.ReadToFollowing("itemNum1");
                            itemNum1 = reader.ReadString();

                            reader.ReadToFollowing("itemId2");
                            itemId2 = reader.ReadString();

                            reader.ReadToFollowing("itemNum2");
                            itemNum2 = reader.ReadString();

                            if (set.Add(evolutionConditionId))
                            {
                                if (builder.Length != 0) builder.Clear();
                                builder.Append(needAwakenlevel + ";" + itemId1 + "," + itemNum1 + ";" + itemId2 + "," + itemNum2);
                                evolutionConditionHK.Add(evolutionConditionId, builder.ToString());
                            }
                            else Add("evolutionConditionId 重复：" + evolutionConditionId);
                        }
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 resetEvolutionList（进化石返还） 表 日月
        /// </summary>
        void LoadResetEvolutionList()
        {
            try
            {
                Start("resetEvolutionList 表存在错误：");
                using (XmlTextReader reader = new XmlTextReader(myPath.resetEvolutionListPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    
                    resetEvolutionListHK = new HashK<string, ResetEvolutionList>();
                    HashSet<string> resetEvolution_Set = new HashSet<string>();
                    HashSet<string> set = new HashSet<string>();
                    HashK<string, StringBuilder[]> tempHK = new HashK<string, StringBuilder[]>();
                    StringBuilder awakenLvB;
                    StringBuilder ItemId_1B;
                    StringBuilder Number_1B;
                    StringBuilder ItemId_2B;
                    StringBuilder Number_2B;
                    StringBuilder resetPokB;
                    StringBuilder[] builders;
                    string resetEvolution = "";
                    string awakenLv = "";
                    string awakenItemId_1 = "";
                    string awakenItemNumber_1 = "";
                    string awakenItemId_2 = "";
                    string awakenItemNumber_2 = "";
                    string resetPokeNumber = "";
                    while (reader.Read())
                    {
                        reader.ReadToFollowing("resetEvolution"); //进化石返还ID
                        resetEvolution = reader.ReadString();

                        reader.ReadToFollowing("awakenLv"); //觉醒的等级
                        awakenLv = reader.ReadString();

                        reader.ReadToFollowing("awakenItemId_1"); //进化材料ID_1
                        awakenItemId_1 = reader.ReadString();

                        reader.ReadToFollowing("awakenItemNumber_1"); //进化材料数量_1
                        awakenItemNumber_1 = reader.ReadString();

                        reader.ReadToFollowing("awakenItemId_2"); //进化材料ID_2
                        awakenItemId_2 = reader.ReadString();

                        reader.ReadToFollowing("awakenItemNumber_2"); //进化材料数量_2
                        awakenItemNumber_2 = reader.ReadString();

                        reader.ReadToFollowing("resetPokeNumber"); //重置返还额外3阶精灵个数
                        resetPokeNumber = reader.ReadString();

                        if (reader.EOF == false)
                        {
                            //判断 key ID 是否能添加进 set 中
                            if (resetEvolution_Set.Add(resetEvolution)) //能添加的表明是新的
                            {
                                set.Clear();
                                if (awakenItemId_1 != awakenItemId_2 & awakenItemId_1 != "0") 
                                {
                                    set.Add(awakenItemId_1);
                                    set.Add(awakenItemId_2);
                                }
                                awakenLvB = new StringBuilder();
                                ItemId_1B = new StringBuilder();
                                Number_1B = new StringBuilder();
                                ItemId_2B = new StringBuilder();
                                Number_2B = new StringBuilder();
                                resetPokB = new StringBuilder();
                                builders = new StringBuilder[] { awakenLvB, ItemId_1B, Number_1B, ItemId_2B, Number_2B, resetPokB };
                                awakenLvB.Append(awakenLv);
                                ItemId_1B.Append(awakenItemId_1);
                                Number_1B.Append(awakenItemNumber_1);
                                ItemId_2B.Append(awakenItemId_2);
                                Number_2B.Append(awakenItemNumber_2);
                                resetPokB.Append(resetPokeNumber);
                                tempHK.Add(resetEvolution, builders);
                                
                            }
                            else //无法添加的说明是重复的
                            {
                                StringBuilder[] builders1 = tempHK.GetTvalue(resetEvolution);

                                builders1[0].Append("," + awakenLv);
                                builders1[5].Append("," + resetPokeNumber);

                                if (awakenItemId_1 != "0") 
                                {
                                    builders1[2].Append("," + awakenItemNumber_1);
                                    if (set.Add(awakenItemId_1))
                                    {
                                        Add(String.Format("resetEvolutionList {0}【Id_1不一致：{1}】", resetEvolution, awakenItemId_1));
                                    }
                                }

                                if (awakenItemId_2 != "0")
                                {
                                    builders1[4].Append("," + awakenItemNumber_2);
                                    if (set.Add(awakenItemId_2))
                                    {
                                        Add(String.Format("resetEvolutionList {0}【Id_2不一致：{1}】", resetEvolution, awakenItemId_2));
                                    }
                                }
                            }
                        }
                        else
                        {
                            foreach (string resetEvolutionid in tempHK.Keys)
                            {
                                StringBuilder[] builders1 = tempHK.GetTvalue(resetEvolutionid);
                                ResetEvolutionList reset = new ResetEvolutionList();
                                reset.awakenLv = builders1[0].ToString();
                                reset.awakenItemId_1 = builders1[1].ToString();
                                reset.awakenItemNumber_1 = builders1[2].ToString();
                                reset.awakenItemId_2 = builders1[3].ToString();
                                reset.awakenItemNumber_2 = builders1[4].ToString();
                                reset.resetPokeNumber = builders1[5].ToString();
                                resetEvolutionListHK.Add(resetEvolutionid, reset);
                            }
                        }
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 PokeCharacter（性格洗练）表 决斗
        /// </summary>
        void LoadPokeCharacter()
        {
            try
            {
                pokeCharacterClearHK = GetXmlXtoY(myPath.pokeCharacterClearPath, 1, "pokeCharacterClear");
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 megaLvSys（Mega强化11级特性）表 决斗
        /// </summary>
        void LoadMegaLvSys()
        {
            try
            {
                Start("megaLvSys 表存在错误：");
                using (XmlTextReader reader = new XmlTextReader(myPath.megaLvSysPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    megaLvSysHK = new HashK<string, string>();
                    HashSet<string> set = new HashSet<string>();
                    string mID = "";
                    string vID = "";
                    while (reader.Read())
                    {
                        if (reader.Depth == 2 & reader.NodeType == XmlNodeType.Element)
                        {
                            reader.ReadToFollowing("megaLv");
                            if (reader.ReadString() == "11")
                            {
                                reader.ReadToFollowing("valueNum");
                                vID = reader.ReadString();
                                reader.ReadToFollowing("megaStrengthenId");
                                mID = reader.ReadString();
                                if (set.Add(mID)) megaLvSysHK.Add(mID, vID);
                                else Add("megaStrengthenId重复：" + mID);
                            }
                        }
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 drop 表（掉落） 新逆袭/新世代
        /// </summary>
        void LoadDrop()
        {
            try
            {
                Start("drop 表存在错误：");
                if (index == 3) //新逆袭
                {
                    using (XmlTextReader reader = new XmlTextReader(myPath.dropPath))
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        dropHK = new HashK<string, string>();
                        string dropId = "";
                        string item_2 = "";
                        string num_2 = "";
                        while (reader.Read())
                        {
                            reader.ReadToFollowing("dropId");
                            dropId = reader.ReadString();
                            reader.ReadToFollowing("item_2");
                            item_2 = reader.ReadString();
                            if (reader.EOF == false)
                            {
                                if (item_2 == "100000015")
                                {
                                    reader.ReadToFollowing("num_2");
                                    num_2 = reader.ReadString();
                                    if (!dropHK.ContainsKey(dropId)) dropHK.Add(dropId, num_2);
                                    else Add("dropId 重复：" + dropId);
                                }
                            }
                        }
                    }
                }
                if (index == 4)//新世代
                {
                    using (XmlTextReader reader = new XmlTextReader(myPath.dropPath))
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        dropHK = new HashK<string, string>();
                        string dropId = "";
                        string item_1 = "";
                        while (reader.Read())
                        {
                            reader.ReadToFollowing("dropId");
                            dropId = reader.ReadString();
                            if (reader.EOF == false)
                            {
                                if (dropId.Contains("162"))
                                {
                                    reader.ReadToFollowing("item_1");
                                    item_1 = reader.ReadString();
                                    if (dropHK.ContainsKey(dropId)) Add("dropId 重复：" + dropId);
                                    else dropHK.Add(dropId, item_1);
                                }
                            }
                        }
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// 读取 disintegrate 表（精灵分解） 决斗/新喵喵
        /// </summary>
        void LoadDisintegrate()
        {
            try
            {
                Start("disintegrate 表存在错误：");
                
                using (XmlTextReader reader = new XmlTextReader(myPath.disintegratePath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    disintegrateHK = new HashK<string, Disintegrate>();
                    Disintegrate disintegrate = new Disintegrate();
                    string petId = "";
                    while (reader.Read())
                    {
                        if (reader.Depth == 2 & reader.NodeType == XmlNodeType.Element)
                        {
                            switch (reader.Name)
                            {
                                case "petId":
                                    petId = reader.ReadString();
                                    break;

                                case "material1_id":
                                    disintegrate.material1_id = reader.ReadString();
                                    break;

                                case "material1_numRange":
                                    disintegrate.material1_numRange = reader.ReadString();
                                    break;

                                case "material2_id":
                                    disintegrate.material2_id = reader.ReadString();
                                    break;

                                case "material2_numRange":
                                    disintegrate.material2_numRange = reader.ReadString();
                                    break;

                                case "material3_id":
                                    disintegrate.material3_id = reader.ReadString();
                                    break;

                                case "material3_numRange":
                                    disintegrate.material3_numRange = reader.ReadString();
                                    break;

                                case "material4_id":
                                    disintegrate.material4_id = reader.ReadString();
                                    break;

                                case "material4_numRange":
                                    disintegrate.material4_numRange = reader.ReadString();
                                    break;

                                case "material5_id":
                                    disintegrate.material5_id = reader.ReadString();
                                    break;

                                case "material5_numRange":
                                    disintegrate.material5_numRange = reader.ReadString();
                                    break;
                            }
                        }
                        if (reader.Depth == 1 & reader.NodeType == XmlNodeType.EndElement)
                        {
                            if (!disintegrateHK.ContainsKey(petId))
                            {
                                disintegrateHK.Add(petId, disintegrate);
                                disintegrate = new Disintegrate();
                            }
                            else Add("petId 重复：" + petId);
                        }
                    }
                }
                
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }

        /// <summary>
        /// z技能 日月 决斗 新逆袭 新世代
        /// </summary>
        void LoadzMove()
        {
            try
            {
                using (XmlTextReader reader = new XmlTextReader(myPath.pmBuffPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    pmBuffHK = new HashK<string, string>();
                    string buffId = default;
                    string buffName = default;
                    Start("pmBuff 表存在错误：");

                    while (reader.Read())
                    {
                        reader.ReadToFollowing("buffId");
                        buffId = reader.ReadString();

                        reader.ReadToFollowing("buffName");
                        buffName = reader.ReadString();

                        if (reader.EOF != true)
                        {
                            if (pmBuffHK.ContainsKey(buffId))
                            {
                                Add("buffId 重复：" + buffId);
                            }
                            else
                            {
                                pmBuffHK.Add(buffId, buffName);
                            }
                        }
                    }

                    End();
                }
            }
            catch (Exception)
            {
                throw;
            }

            if (index == 0)
            {
                try
                {
                    using (XmlTextReader reader = new XmlTextReader(myPath.pmBuffListPath))
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        pmBuffListHK = new HashK<string, PmBuffList>();
                        PmBuffList pmBuffList = new PmBuffList();
                        List<string> list = new List<string>();
                        HashSet<string> set = new HashSet<string>();
                        string buffListId = default;
                        string buffId_1 = default;
                        string buffId_2 = default;
                        string buffId_3 = default;
                        string buffId_4 = default;
                        string buffId_5 = default;
                        Start("pmBuffList 表存在错误：");

                        while (reader.Read())
                        {
                            reader.ReadToFollowing("buffListId");
                            buffListId = reader.ReadString();

                            reader.ReadToFollowing("buffId_1");
                            buffId_1 = reader.ReadString();

                            reader.ReadToFollowing("buffId_2");
                            buffId_2 = reader.ReadString();

                            reader.ReadToFollowing("buffId_3");
                            buffId_3 = reader.ReadString();

                            reader.ReadToFollowing("buffId_4");
                            buffId_4 = reader.ReadString();

                            reader.ReadToFollowing("buffId_5");
                            buffId_5 = reader.ReadString();

                            if (reader.EOF != true)
                            {
                                if (pmBuffListHK.ContainsKey(buffListId))
                                {
                                    Add("buffListId 重复：" + buffListId);
                                }
                                else
                                {
                                    string ChackBuffId(string buffId)
                                    {
                                        if (buffId != "0")
                                        {
                                            if (pmBuffHK.ContainsKey(buffId))
                                            {
                                                buffId = pmBuffHK[buffId].ToString();
                                                if (!set.Add(buffId))
                                                {
                                                    Add("buffListId[ " + buffListId + " ]-> buffId[ " + buffId + " ] 错误，tips: 已存在相同的 buffId");
                                                }
                                            }
                                            else
                                            {
                                                Add("buffListId[ " + buffListId + " ] -> buffId[ " + buffId + " ] 错误，tips: 该 ID 不在 pmBuff 表中");
                                                buffId = "异常";
                                            }
                                        }
                                        return buffId;
                                    }

                                    pmBuffList.buffId_1 = ChackBuffId(buffId_1);
                                    pmBuffList.buffId_2 = ChackBuffId(buffId_2);
                                    pmBuffList.buffId_3 = ChackBuffId(buffId_3);
                                    pmBuffList.buffId_4 = ChackBuffId(buffId_4);
                                    pmBuffList.buffId_5 = ChackBuffId(buffId_5);
                                    pmBuffListHK.Add(buffListId, pmBuffList);
                                    pmBuffList = new PmBuffList();
                                    set.Clear();

                                }
                            }
                        }
                        
                        End();
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                try
                {
                    using (XmlTextReader reader = new XmlTextReader(myPath.zMovePath))
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        zMoveHK = new HashK<string, string>();
                        HashSet<string> zSet = new HashSet<string>();
                        HashSet<string> bSet = new HashSet<string>();
                        HashSet<string> set1 = default;
                        HashSet<string> set2 = default;
                        string skillId = default;
                        string skillGrade = default;
                        string buffId_1 = default;
                        string buffId_2 = default;
                        string buff = default;
                        Start("zMove 表存在错误：");
                        while (reader.Read())
                        {
                            reader.ReadToFollowing("skillId");
                            skillId = reader.ReadString();
                            reader.ReadToFollowing("skillGrade");
                            skillGrade = reader.ReadString();
                            reader.ReadToFollowing("buff");
                            buff = reader.ReadString();
                            if (reader.EOF != true)
                            {
                                if (skillGrade == "1")
                                {
                                    if (zSet.Contains(skillId))
                                    {
                                        Add("skillId 重复：" + skillId);
                                        break;
                                    }
                                }

                                if (!zMoveHK.ContainsKey(skillId))
                                {
                                    if (bSet.Count < 4)
                                    {
                                        bSet.Add(buff);
                                    }
                                    else
                                    {
                                        Add("skillId[ " + skillId + " ] 多出一个 buffId：" + buff);
                                    }

                                    string[] GetPmBuffList()
                                    {
                                        PmBuffList pmBuffList = pmBuffListHK.GetTvalue(buff);
                                        return new string[] { pmBuffList.buffId_1, pmBuffList.buffId_2, pmBuffList.buffId_3, pmBuffList.buffId_4, pmBuffList.buffId_5 };
                                    }

                                    if (skillGrade == "6")
                                    {
                                        if (pmBuffListHK.ContainsKey(buff))
                                        {
                                            set1 = new HashSet<string>(GetPmBuffList());
                                            foreach (var item in set1)
                                            {
                                                buffId_1 += item + " ";
                                            }
                                        }
                                        else if (buff != "0")
                                        {
                                            Add("skillId[ " + skillId + " ] 的 6级buff[ " + buff + " ] 不在 pmBuffList 表中");
                                            buffId_1 = "异常";
                                        }
                                        else
                                        {
                                            buffId_1 = buff;
                                        }

                                    }
                                    if (skillGrade == "11")
                                    {
                                        if (pmBuffListHK.ContainsKey(buff))
                                        {
                                            PmBuffList pmBuffList = pmBuffListHK.GetTvalue(buff);
                                            set2 = new HashSet<string>(GetPmBuffList());
                                            if (set1 != null)
                                            {
                                                if (!set1.IsProperSubsetOf(set2))
                                                {
                                                    Add("skillId[ " + skillId + " ] 的 6级 buff[ " + buffId_1 + " ] 不在 11级 buff[ " + buff + " ]  中");
                                                }
                                            }

                                            foreach (var item in set2)
                                            {
                                                buffId_2 += item + " ";
                                            }

                                        }
                                        else if (buff != "0")
                                        {
                                            Add("skillId[ " + skillId + " ] 的 11级buff[ " + buff + " ] 不在 pmBuffList 表中");
                                            buffId_2 = "异常";
                                        }
                                        else
                                        {
                                            Add("skillId[ " + skillId + " ] 的 11级buff[ " + buff + " ] 不能为0");
                                            buffId_2 = buff;
                                        }
                                    }
                                    if (skillGrade == "15")
                                    {
                                        buff = string.Format("[6级：{0}] [11级：{1}]", buffId_1, buffId_2);
                                        zMoveHK.Add(skillId, buff);
                                        buffId_1 = default;
                                        buffId_2 = default;
                                        bSet.Clear();
                                        set1.Clear();
                                        set2.Clear();
                                        zSet.Add(skillId);
                                        
                                        
                                    }
                                }
                            }
                        }
                        End();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
            else
            {
                try
                {
                    using (XmlTextReader reader = new XmlTextReader(myPath.zMovePath))
                    {
                        reader.WhitespaceHandling = WhitespaceHandling.None;
                        zMoveHK = new HashK<string, string>();
                        HashSet<string> zSet = new HashSet<string>();
                        HashSet<string> bSet = new HashSet<string>();
                        string skillId = default;
                        string skillGrade = default;
                        string buff = default;
                        string buffId_1 = default;
                        string buffId_2 = default;
                        string buffId_3 = default;
                        Start("zMove 表存在错误：");
                        while (reader.Read())
                        {
                            reader.ReadToFollowing("skillId");
                            skillId = reader.ReadString();

                            reader.ReadToFollowing("skillGrade");
                            skillGrade = reader.ReadString();

                            reader.ReadToFollowing("buff");
                            buff = reader.ReadString();

                            if (reader.EOF != true)
                            {
                                if (skillGrade == "1")
                                {
                                    if (zSet.Contains(skillId))
                                    {
                                        Add("skillId 重复：" + skillId);
                                        break;
                                    }
                                }

                                string ChackBuff()
                                {
                                    string[] tempBuff;
                                    if (buff == "0")
                                    {
                                        Add("skillId[ " + skillId + " ] 的 " + skillGrade + " 级buff[ " + buff + " ] 不能为0");
                                        return skillGrade + "级：0,0,0";
                                    }
                                    else
                                    {
                                        tempBuff = buff.Split(';');
                                    }

                                    for (int i = 0; i < tempBuff.Length; i++)
                                    {
                                        if (pmBuffHK.ContainsKey(tempBuff[i]))
                                        {
                                            tempBuff[i] = pmBuffHK[tempBuff[i]].ToString();
                                        }
                                        else if (buff != "0")
                                        {
                                            tempBuff[i] = "异常";
                                            Add("skillId[ " + skillId + " ] 的 " + skillGrade + " 级buff[ " + tempBuff[i] + " ] 不在 pmBuff 表中");
                                        }
                                        else
                                        {
                                            tempBuff[i] = "异常";
                                            Add("skillId[ " + skillId + " ] 的 " + skillGrade + " 级buff[ " + tempBuff[i] + " ] 不能为 0");
                                        }
                                    }
                                    return string.Format("{0}级：{1}, {2}, {3}", skillGrade, tempBuff[0], tempBuff[1], tempBuff[2]);
                                }

                                if (!zMoveHK.ContainsKey(skillId))
                                {
                                    switch (skillGrade)
                                    {
                                        case "5":
                                            buffId_1 = ChackBuff();
                                            break;
                                        case "10":
                                            buffId_2 = ChackBuff();
                                            break;
                                        case "15":
                                            buffId_3 = ChackBuff();
                                            buff = string.Format("[{0}] [{1}] [{2}]", buffId_1, buffId_2, buffId_3);
                                            zMoveHK.Add(skillId, buff);
                                            bSet.Clear();
                                            zSet.Add(skillId);
                                            break;
                                    }
                                }
                            }
                        }
                        End();
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }
        }

        /// <summary>
        /// 升阶 新逆袭
        /// </summary>
        void LoadupgradeCondition()
        {
            try
            {
                Start("upgradeCondition 表存在错误：");

                using (XmlTextReader reader = new XmlTextReader(myPath.upgradeConditionPath))
                {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                    upgradeConditionDic = new Dictionary<string, int>();
                    Dictionary<string, HashSet<string>> dic = new Dictionary<string, HashSet<string>>();
                    string upgradeConditionId = default;
                    string petQuality = default;
                    while (reader.Read())
                    {
                        reader.ReadToFollowing("upgradeConditionId");
                        upgradeConditionId = reader.ReadString();
                        if (reader.EOF == false)
                        {
                            reader.ReadToFollowing("petQuality");
                            petQuality = reader.ReadString();
                            if (dic.ContainsKey(upgradeConditionId))
                            {
                                if (dic[upgradeConditionId].Contains(petQuality))
                                {
                                    Add("upgradeConditionId ["+upgradeConditionId +"] /petQuality 重复：" + petQuality);
                                }
                                else
                                {
                                    dic[upgradeConditionId].Add(petQuality);
                                }
                            }
                            else
                            {
                                dic.Add(upgradeConditionId, new HashSet<string>());
                                dic[upgradeConditionId].Add(petQuality);
                            }
                        }
                    }

                    foreach (var item in dic)
                    {
                        upgradeConditionDic.Add(item.Key,item.Value.Count);
                    }
                }
                End();
            }
            catch (Exception)
            {
                throw;
            }
        }
    }
}
